<%@page import="com.aimee.entity.User"%>
<%@page import="com.aimee.util.PageBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="java.util.List"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生管理</title>
 <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
	<%
		List<User> list = (List) request.getAttribute("apage");
		PageBean pb = (PageBean) request.getAttribute("pb");
	%>
	<H1>学生管理</H1>
	<button class="btnAddStu">创建学生</button>
	<button class="btnAddMore">批量导入</button>
	<hr>
	<table border=1 width="80%">
		<tr>
			<th><input type="checkbox"></th>
			<th>姓名</th>
			<th>性别</th>
			<th>班级</th>
			<th>电话</th>
			<th>微信</th>
			<th>操作</th>
		</tr>
<%-- 		<%
		for(User u:list){
			out.print("<tr>");
			out.print("<td><input type='checkbox' name='st'></td>");
			out.print("	<td>"+u.getUser_name()+"</td>");
			out.print("<td>男</td>");
			out.print("<td>1</td>");
			out.print("<td>2222222</td>");
			out.print("<td>22</td>");
			out.print("<td><button>查看</button>");
			out.print("	<button class='updateStu' dataid='"+u.getUser_id()+"'dataname='"+u.getUser_name()+"'>修改</button>");
			out.print("<button class='btndel' dataid='"+u.getUser_id()+"'>删除</button></td>");
			out.print("</tr>");
		}
		%> --%>
		<c:forEach items="${apage}" var="stu">
		 <tr>
		 <td><input type='checkbox' name='st'></td>
		 	<td>${stu.user_name}</td>
		 	<td>男</td>
		 	<td>1</td>
		 	<td>2222222</td>
		 	<td>22</td>
		 	<td><button>查看</button>
		 	<button class='updateStu' dataid='${stu.user_id}'dataname='${stu.user_name}'>修改</button>
		    <button class='btndel' dataid='${stu.user_id}'>删除</button></td>
		</tr>
		</c:forEach>
	</table>
	<hr>
<!-- 	<h1>分页信息</h1> -->
<%-- <%
  for(int i=pb.getBeginNum();i<pb.getEndNum();i++){
	  out.println("<a href='student?m=page&p="+i+"'>"+i+"</a>");
  }
%> --%>
<c:forEach begin="${pb.beginNum}" end="${pb.endNum}" varStatus="k">
  <c:if test="${k.index==pb.curPage }">
   <a style='color:red' href='student?m=page&p=${k.index }'>${k.index }</a>
  </c:if>
   <c:if test="${k.index!=pb.curPage }">
   <a  href='student?m=page&p=${k.index }'>${k.index }</a>
  </c:if>
</c:forEach>
<script src="../layui/layui.js"></script>
<script>
//批量导入
 layui.use('layer',function(){
	 var $=layui.jquery,layer=layui.layer;
	 $(".btnAddMore").click(function(){
		 layer.open({
			 title:"在线调试",
			 content:'<h1>批量导入</h1>'
		 });
	 });
	 
	//所有删除 加事件
	 $(".btndel").click(function(){
		 var id=$(this).attr("dataid");
		 layer.confirm('您确定删除该用户？',{btn:['确定','取消'],title:"提示"},function(index){
			 console.log("del ok"+id);
			 location.href="http://localhost:8080/OnlineExam/admin/student?m=del&uid="+id;
			 layer.close(index);
		 });
	 });
	 //创建学生 跳转页面
	  $(".btnAddStu").click(function(){
		  location.href="http://localhost:8080/OnlineExam/admin/addstu.html";
	  })
	  //修改学生信息
	   $(".updateStu").click(function(){
			  var id=$(this).attr("dataid");
			  var name=$(this).attr("dataname");
		  location.href="http://localhost:8080/OnlineExam/admin/updatestu.jsp?user_id="+id+"&user_name="+name;	
	   })
	  //批量导入
	   $(".btnAddMore").click(function(){
		  location.href="http://localhost:8080/OnlineExam/admin/student-upload.jsp";
	  })
 })
 //
 /*function delStu(stid){
	 alert("是否要删除"+stid+"号学生");
 }*/

</script>
</body>
</html>